package ${basePackege}.${module}.api;

import com.github.pagehelper.PageInfo;
import com.gzkit.baseframework.core.beans.DefaultResultBean;
import com.gzkit.baseframework.core.beans.page.PageQuery;
import com.gzkit.baseframework.core.utils.Result;
import ${basePackege}.${module}.service.${entity}Service;
import ${basePackege}.${module}.vo.${entity}VO;
import ${basePackege}.${module}.dto.${entity}Query;
import ${basePackege}.${module}.dto.${entity}Insert;
import ${basePackege}.${module}.dto.${entity}Update;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.gzkit.baseframework.core.validator.KitValidOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("${r'${restPath}'}/${moduleName?uncap_first}")
@Api(tags = "${tableComment}接口")
class ${entity}Api {
    @Autowired
    private ${entity}Service ${entity?uncap_first}Service;

	@ApiOperation("分页查询")
    @PostMapping("/listByPage")
    public DefaultResultBean<PageInfo<${entity}VO>> listByPage(@RequestBody PageQuery<${entity}Query> pageQuery) {
        return Result.success(${entity?uncap_first}Service.listByPage(pageQuery));
    }

	@ApiOperation("插入根据id")
	@PostMapping("/insert")
	@KitValidOperation
	public DefaultResultBean insert(@RequestBody ${entity}Insert inertDTO) {
		return Result.success(${entity?uncap_first}Service.insert(inertDTO));
	}

    @ApiOperation("更新根据id")
    @PostMapping("/update")
	@KitValidOperation
    public DefaultResultBean update(@RequestBody ${entity}Update updateDTO) {
        return Result.success(${entity?uncap_first}Service.updateById(updateDTO));
    }

	@ApiOperation("删除根据id")
	@PostMapping("/delete/{id}")
	public DefaultResultBean delete(@PathVariable String id) {
		return Result.success(${entity?uncap_first}Service.deleteById(id));
	}

	@ApiOperation("根据id查询")
    @GetMapping("/detail/{id}")
    public DefaultResultBean detail(@PathVariable String id) {
        return Result.success(${entity?uncap_first}Service.selectByPrimaryKey(id));
    }
}